import request from '@/utils/request'

//获取分页形式用户数据列表
export function getUsers(data) {
	return request({
		url: '/sys/user',
		method: 'get',
		params: data
	})
}
//获取用户信息接口
export function getInfo(token) {
	return request({
		url: '/detailsUser',
		method: 'get',
		params: {
			token
		}
	})
}
// 根据userId获取用户数据
export function getUser(data) {
	return request({
		url: '/sys/user/' + data.userId,
		method: 'get',
	})
}
// 创建用户
export function addUser(data) {
	return request({
		url: '/sys/user',
		method: 'post',
		data
	})
}
// 更新用户数据
export function updateUser(data) {
	return request({
		url: '/sys/user',
		method: 'put',
		data
	})
}
// 修改用户密码
export function updateUserPassword(data) {
	return request({
		url: '/sys/user/pwdReset',
		method: 'put',
		params: data
	})
}
// 调整用户状态
export function updateUserState(data) {
	return request({
		url: '/sys/user/' + data.userId,
		method: 'put',
	})
}
//删除用户
export function deleteUser(data) {
	return request({
		url: '/sys/user',
		method: 'delete',
		params: data
	})
}

//获取组织人员
export function orgMembers(data) {
	return request({
		url: '/api/user/teacherListSameByOrg',
		method: 'get',
		params: data
	})
}

//导入用户
export function importExcel(data) {
	return request({
		url: '/sys/user/importExcel',
		method: 'post',
		data
	})
}

// 修改当前用户密码
export function updateMyPassword(data) {
	return request({
		url: '/sys/user/updateMyPassword?password='+data.password+'&oldpassword='+data.oldpassword,
		method: 'put',
	})
}

//用户解锁
export function userUnlock(data) {
	return request({
		url: '/sys/user/userUnlock',
		method: 'post',
		data
	})
}

//获取教师管理的组织
export function getOrgChildrenTree(data) {
	return request({
		url: '/system/sysUserTeacherDeptDO/teacherDeptTree',
		method: 'get',
		params: data
	})
}
